//
//  UIBarButton+Extension.swift
//  weibo
//
//  Created by GOD on 16/9/3.
//  Copyright © 2016年 磊王. All rights reserved.
//

import UIKit

extension UIBarButtonItem {
    /**
     创建UIBarButtonItem
     
     - parameter title:    title名称
     - parameter fontSize: 字体大小，默认为16
     - parameter target:   target
     - parameter action:   执行的函数
     - parameter isBackButton : 是否是返回按钮
     
     */
        convenience init(title:String,fontSize :CGFloat = 16,target:AnyObject?,action:Selector ,isBackButton : Bool = false) {
        let btn = UIButton.cz_textButton(title, fontSize:fontSize, normalColor: UIColor.grayColor(), highlightedColor: UIColor.orangeColor())
        btn.addTarget(target, action: action, forControlEvents: .TouchUpInside)
        
        if isBackButton {
            let imageName = "navigationbar_back_withtext"
            btn.setImage(UIImage(named: imageName), forState: .Normal)
            btn.setImage(UIImage(named: imageName+"_highlighted"), forState: .Highlighted)
            btn.sizeToFit()
            
        
        }
        
        self.init(customView: btn)
    }

}